<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>后台管理</title>
{{include file="layouts/_head"}}
</head>
<body>
<div class="main">
	<ol class="breadcrumb">
		<li><i class="icon_home iconfont"></i>首页</li>
	  	<li>微信小程序</li>
	  	<li><a href="javascript:history.go(-1);">首页九宫格</a></li>
	  	<li class="active">编辑</li>
	</ol>
	<div class="bg-danger clearfix main-head-info error-info"></div>
	<div class="main-con">
		<form class="form-horizontal margin-t-30" id="form" method="post" action="{{:url('/admin/wxapp/update_sudoku')}}" >
			<input type="hidden" name="id" value="{{$sudoku.id}}">
		  	<div class="tab-box">	
			  	<div class="form-group">
			    	<span class="col-sm-2 control-label"><span class="color-red">*</span> 标题：</span>
			    	<div class="col-sm-8 input-group"><input class="form-control" name="title" value="{{$sudoku.title}}"></div>
			  	</div>
			  	<div class="form-group">
                    <span class="col-sm-2 control-label"><i class="iconfont iconfont-question" data-toggle="tooltip" data-placement="top" data-original-title="建议尺寸：50X50"></i> <span class="color-red">*</span> 图标：</span>
                    <div class="col-sm-4 input-group">
                        <div class="fmr wh-60x60 {{if !empty($sudoku.image)}} uploaded {{/if}}" data-name="image">
                        	{{if !empty($sudoku.image)}}
                    		<input name="image" type="hidden" value="{{$sudoku.image}}"><img src="{{$sudoku.image}}"><i class="iconfont fmr_remove"></i>
                    		{{/if}}
                        </div>
                    </div>
                </div>
			  	<div class="form-group">
				    <span class="col-sm-2 control-label"><i class="iconfont iconfont-question" data-toggle="tooltip" data-placement="top" data-original-title="建议开发人员设置"></i> 页面链接：</span>
				    <div class="col-sm-8 input-group">
				      <input class="form-control" name="page_url" value="{{$sudoku.page_url}}">
				    </div>
				</div>
				<div class="form-group">
				    <span class="col-sm-2 control-label">页面标识：</span>
				    <div class="col-sm-2 input-group">
					<select class="form-control" name="page_ident">
						<option value="1" {{if $sudoku.page_ident == 1}}selected="true"{{/if}}>内部页面</option>
						<option value="2" {{if $sudoku.page_ident == 2}}selected="true"{{/if}}>外部链接</option>
					</select>
				    </div>
				</div>
				<div class="form-group">
				    <span class="col-sm-2 control-label">排序：</span>
				    <div class="col-sm-2 input-group">
				      <input class="form-control" name="sort" value="{{$sudoku.sort}}">
				    </div>
				</div>
				<div class="form-group">
				    <span class="col-sm-2 control-label">状态：</span>
				    <div class="col-sm-2 input-group">
					<select class="form-control" name="status">
						<option value="1" {{if $sudoku.status == 1}}selected="true"{{/if}}>开启</option>
                        <option value="0" {{if $sudoku.status == '0'}}selected="true"{{/if}}>关闭</option>
					</select>
				    </div>
				</div>
			</div>
			<div class="foot_btn_blank"></div>
            <div class="foot_btn">
                <div class="box">
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
		</form>
	</div>
</div>
{{include file="layouts/_foot"}}
{{include file="shared/_jquery_validation"}}
<script type="text/javascript">
$("#form").validate({
	rules: {
		title: {required: true},
		image: {required: true},
	},
	messages: {
		title: '标题不能为空',
		image: '图标不能为空',
	},
	submitHandler:function(){
		layer.confirm('确认提交？', function() {
			layer.closeAll(); var load = layer.load();
			$("#form").ajaxSubmit(function(res) {
				layer.close(load);
                if (res.code == 401) {
                    goLogin(); return false;
                }
                if (res.code == 200) {
                    layer.msg('提交成功', {time: 1500}, function() {window.location.href = '{{:url("/admin/wxapp/sudoku")}}'});
                } else if (res.code == 400) {
                    layer.msg(res.message); return false;
                } else {
                    layer.msg('操作失败'); return false;
                }
			});
		});	
	}
});

</script>
</body>
</html>